<?php

namespace addons\yunfood\model;

use addons\yunfood\library\ModelTrait;
use think\Model;
use traits\model\SoftDelete;

/**
 * 菜品规格模型
 */
class FoodSpec extends Model
{
    use ModelTrait;
    use SoftDelete;

    // 表名,不含前缀
    protected $name = 'yunfood_food_spec';

    // 自动写入时间戳字段
    protected $autoWriteTimestamp = true;

    // 定义时间戳字段名
    protected $deleteTime = 'deleted_at';
    protected $updateTime = 'updated_at';
    protected $createTime = 'created_at';

    // 不显示的字段
    protected $hidden = ['deleted_at'];

    protected $resultSetType = 'collection';

    // 上级数据
    public function parentData()
    {
        return $this->hasOne(self::class, 'id', 'parent_id');
    }
}
